home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 1.5 KB | 60 lines | [TEXT/ToyS] |
- property kasResType : "PICT" -- Picture resources
- property kasOutType : "PICT" -- Picture file type
- property kasOutApp : "ttxt" -- Creator for output file
- property kasHeader : 512 -- Bytes header in output file
-
- on run
- choose file with prompt "Choose a file to extract pictures from…"
- open {the result}
- end run
-
-
- on open fsObjs
- repeat with fsObj in fsObjs
- DoFile(fsObj)
- end repeat
- end open
-
-
- on DoFile(fsObj)
- set fname to catalog name of (basic info for fsObj)
- set dstFold to a new folder in fsObj named (fname & " " & kasResType & "s")
- set rsrcs to (the number of resources in fsObj of type kasResType with their info)
-
- set n to the number of items in rsrcs
- set pg to display progress titled fname maximum n
-
- -- {{rName, rNum, rFlags}, {...}}
- repeat with r in rsrcs
- -- Get resource
- set gotOne to true
- try
- set rsrc to the resource in fsObj of type kasResType ¬
- numbered (item 2 of r)
- on error
- display progress pg labeled ("Error reading: " & (item 2 of r))
- set gotOne to false
- end try
-
- if (gotOne) then
- -- Name?
- copy item 1 of r to rName
- if (rName is "") then set rName to "#" & (item 2 of r)
-
- -- Update progress
- display progress pg value 0 subtitled rName
-
- -- Create file
- set outFile to a new file in dstFold named rName ¬
- of type kasOutType with creator kasOutApp
-
- -- Write data
- write data to the data fork of outFile from buffer rsrc at offset kasHeader
- end if
- end repeat
-
- display progress pg with disposal
- end DoFile
-
-
-